package com.wty.cmims.controller;

import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.service.MedicalDeviceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/medicalDevice")
@Tag(name = "医疗器械信息", description = "社区医疗信息后台管理系统api接口")
public class MedicalDeviceController {
    @Autowired
    private MedicalDeviceService medicalDeviceService;

    // 医疗器械信息获取
    @PostMapping("/find")
    @Operation(summary = "医疗器械信息获取", description = "医疗器械信息获取")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> medicalDeviceFind(@RequestBody Map<String,Object> paramsMap){
        return medicalDeviceService.medicalDeviceFind(paramsMap);
    }

    // 医疗器械信息修改
    @PutMapping("/update")
    @Operation(summary = "医疗器械信息修改", description = "医疗器械信息修改")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> medicalDeviceUpdate(@RequestBody Map<String,Object> paramsMap){
        return medicalDeviceService.medicalDeviceUpdate(paramsMap);
    }

    // 添加医疗器械
    @PostMapping("/add")
    @Operation(summary = "添加医疗器械", description = "添加医疗器械")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> medicalDeviceAdd(@RequestBody Map<String,Object> paramsMap){
        return medicalDeviceService.medicalDeviceAdd(paramsMap);
    }

    // 删除医疗器械
    @PutMapping("/delete")
    @Operation(summary = "删除医疗器械", description = "删除医疗器械")
    @Parameter(name = "id",description = "医疗器械ID")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> deleteMedicalDevice(@RequestParam(name = "id") Integer medicalDeviceId){
        return medicalDeviceService.medicalDeviceDelete(medicalDeviceId);
    }

    // 已有医疗器械下拉框
    @PostMapping("/findDeviceDropDown/{institutionId}")
    @Operation(summary = "医疗器械下拉框", description = "医疗器械下拉框")
    @Parameter(name = "device",description = "医疗器械信息")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> deviceDropDownFind(@PathVariable("institutionId") Integer institutionId){
        return medicalDeviceService.deviceDropDownFind(institutionId);
    }

    // 未有医疗器械下拉框
    @PostMapping("/findDeviceDropDownWithout/{institutionId}")
    @Operation(summary = "医疗器械下拉框", description = "医疗器械下拉框")
    @Parameter(name = "device",description = "医疗器械信息")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> deviceDropDownWithoutFind(@PathVariable("institutionId") Integer institutionId){
        return medicalDeviceService.deviceDropDownWithoutFind(institutionId);
    }
}